package com.mocha.bass.test.hanyuan;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;

import java.util.ArrayList;
import java.util.List;

public class ExcelReadUtile {

    public static List<CameraInfo> readeData(String fileName){
        // 指定要读取的 Excel 文件路径
//        String fileName = "path/to/your/excel/file.xlsx";

        List<CameraInfo> list = new ArrayList<>();
        // 创建一个 EasyExcel 读取器
        EasyExcel.read(fileName, CameraInfo.class, new ReadListener<CameraInfo>() {
            @Override
            public void invoke(CameraInfo data, AnalysisContext context) {
                list.add(data);
                // 在这里处理读取的数据
                System.out.println("Name: " + data);
            }

            @Override
            public void doAfterAllAnalysed(AnalysisContext context) {
                // 所有数据读取完成后的操作
                System.out.println("read success");
            }
        }).sheet().doRead();

        return list ;
    }

    public static void main(String[] args) {
        List<CameraInfo> list = readeData("d:/cm.xlsx");
        System.out.println("============="+ list.size() +"=====================");
    }
}
